/* 
 * File:   Game.h
 * Author: agu
 *
 * Created on 22 de mayo de 2014, 14:45
 */

#ifndef GAME_H
#define	GAME_H
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <vector>
#include <queue>
#include "client_Window.h"
#include "client_InitializationException.h"
#include "client_Runner.h"
#include "client_socket.h"
#include "client_AnimationPlayer.h"
#include "client_TileMap.h"
#include "client_Music.h"
#include "client_Sound.h"
using std::vector;
using std::queue;

class Game : public Runner {
public:
    Game(string name);
    Game(Window& windows, SDL_Renderer* renderer);
    ~Game();
    //void init();
    void run();
    queue<string>* getKeys();
    bool isRunning();
    void setSocket(Client_socket s);
    void setPlayerCode(const string code);
    void setInitialTileMap(const string tileMap);
    string getPlayerCode();
private:
    Client_socket socket;
    bool recibir;
    Window window;
    SDL_Renderer* renderer;
    SDL_Event m_evento;
    AnimationPlayer* player; //Personajes    
    SDL_Event event;
    queue<string>* keys;
    bool running;
    string tileString;
    string playerCode;
    TileMap tileMap;
    Uint32 start;
//    Music music;
    Sound sound;
    void input();
    void handleEvent();
    void update();
    void render();
    void loadGraphics();
    void loadAudio();
    void loadMap();
    void loadPlayer();
    void updateMovements();
    void updateMap();
    void playEffects();
    void renderMap();
    void renderPlayer();
    void freePlayer();
    void send();
    void recv();
    void fps();

};

#endif	/* GAME_H */

